/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package edu.upn.sigemfi.seg.be;

import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.PrimaryKeyJoinColumn;
import javax.persistence.Table;

/**
 *
 * @author Administrador
 */
@Entity
@Table(name = "SEG_PERSONA_JURIDICA")
@PrimaryKeyJoinColumn(name = "FID_SEG_PERSONA", referencedColumnName = "ID_PERSONA")
@DiscriminatorValue(value = "PEJ")
public class PersonaJuridica
        extends Persona
        implements Serializable {

    @Column(name = "RUC", length = 11)
    private String ruc;
    @Column(name = "RAZON_SOCIAL", length = 50)
    private String razonSocial;
    //Representante Legal
    @JoinColumn(name = "FID_REPRESENTANTE_LEGAL", referencedColumnName = "ID_PERSONA")
    @ManyToOne(fetch = FetchType.LAZY)
    private Persona fidRepresentate;

    public PersonaJuridica() {
    }

    public PersonaJuridica(Long idPersona) {
        super(idPersona);
    }

    public String getRazonSocial() {
        return razonSocial;
    }

    public void setRazonSocial(String razonSocial) {
        this.razonSocial = razonSocial;
    }

    public String getRuc() {
        return ruc;
    }

    public void setRuc(String ruc) {
        this.ruc = ruc;
    }

    public Persona getFidRepresentate() {
        return fidRepresentate;
    }

    public void setFidRepresentate(Persona fidRepresentate) {
        this.fidRepresentate = fidRepresentate;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final Persona other = (Persona) obj;
        if (this.idPersona != other.idPersona && (this.idPersona == null || !this.idPersona.equals(other.idPersona))) {
            return false;
        }
        return true;
    }

    @Override
    public int hashCode() {
        int hash = 5;
        hash = 83 * hash + (this.idPersona != null ? this.idPersona.hashCode() : 0);
        return hash;
    }

    @Override
    public String toString() {
        return "edu.upn.sigemfi.seg.be.PersonaJuridica[idPersona=" + idPersona + "]";
    }
}
